package o;

import android.view.View;
import android.view.ViewGroup.LayoutParams;
import androidx.recyclerview.widget.RecyclerView.s;
import java.util.ArrayList;
import java.util.List;

public class mg {
    final c ˊ;
    final b ˎ = new b();
    final List<View> ˏ = new ArrayList();

    static class b {
        long ˊ = 0;
        b ˋ;

        b() {
        }

        void ॱ(int i) {
            if (i >= 64) {
                ˎ();
                this.ˋ.ॱ(i - 64);
                return;
            }
            this.ˊ |= 1 << i;
        }

        private void ˎ() {
            if (this.ˋ == null) {
                this.ˋ = new b();
            }
        }

        void ˊ(int i) {
            if (i < 64) {
                this.ˊ &= (1 << i) ^ -1;
            } else if (this.ˋ != null) {
                this.ˋ.ˊ(i - 64);
            }
        }

        boolean ˏ(int i) {
            if (i < 64) {
                return (this.ˊ & (1 << i)) != 0;
            } else {
                ˎ();
                return this.ˋ.ˏ(i - 64);
            }
        }

        void ˏ() {
            this.ˊ = 0;
            if (this.ˋ != null) {
                this.ˋ.ˏ();
            }
        }

        void ˊ(int i, boolean z) {
            if (i >= 64) {
                ˎ();
                this.ˋ.ˊ(i - 64, z);
                return;
            }
            boolean z2 = (this.ˊ & Long.MIN_VALUE) != 0;
            long j = (1 << i) - 1;
            this.ˊ = (((j ^ -1) & this.ˊ) << 1) | (this.ˊ & j);
            if (z) {
                ॱ(i);
            } else {
                ˊ(i);
            }
            if (z2 || this.ˋ != null) {
                ˎ();
                this.ˋ.ˊ(0, z2);
            }
        }

        boolean ˎ(int i) {
            if (i >= 64) {
                ˎ();
                return this.ˋ.ˎ(i - 64);
            }
            long j = 1 << i;
            boolean z = (this.ˊ & j) != 0;
            this.ˊ &= j ^ -1;
            j--;
            this.ˊ = Long.rotateRight((j ^ -1) & this.ˊ, 1) | (this.ˊ & j);
            if (this.ˋ == null) {
                return z;
            }
            if (this.ˋ.ˏ(0)) {
                ॱ(63);
            }
            this.ˋ.ˎ(0);
            return z;
        }

        int ˋ(int i) {
            if (this.ˋ == null) {
                if (i >= 64) {
                    return Long.bitCount(this.ˊ);
                }
                return Long.bitCount(this.ˊ & ((1 << i) - 1));
            } else if (i < 64) {
                return Long.bitCount(this.ˊ & ((1 << i) - 1));
            } else {
                return this.ˋ.ˋ(i - 64) + Long.bitCount(this.ˊ);
            }
        }

        public String toString() {
            if (this.ˋ == null) {
                return Long.toBinaryString(this.ˊ);
            }
            return this.ˋ.toString() + "xx" + Long.toBinaryString(this.ˊ);
        }
    }

    public interface c {
        s ˊ(View view);

        int ˋ(View view);

        View ˋ(int i);

        void ˎ();

        void ˎ(int i);

        void ˎ(View view);

        int ˏ();

        void ˏ(View view);

        void ˏ(View view, int i);

        void ˏ(View view, int i, LayoutParams layoutParams);

        void ॱ(int i);
    }

    public mg(c cVar) {
        this.ˊ = cVar;
    }

    private void ᐝ(View view) {
        this.ˏ.add(view);
        this.ˊ.ˏ(view);
    }

    private boolean ʼ(View view) {
        if (!this.ˏ.remove(view)) {
            return false;
        }
        this.ˊ.ˎ(view);
        return true;
    }

    public void ˋ(View view, boolean z) {
        ˎ(view, -1, z);
    }

    public void ˎ(View view, int i, boolean z) {
        int ˏ;
        if (i < 0) {
            ˏ = this.ˊ.ˏ();
        } else {
            ˏ = ʼ(i);
        }
        this.ˎ.ˊ(ˏ, z);
        if (z) {
            ᐝ(view);
        }
        this.ˊ.ˏ(view, ˏ);
    }

    private int ʼ(int i) {
        if (i < 0) {
            return -1;
        }
        int ˏ = this.ˊ.ˏ();
        int i2 = i;
        while (i2 < ˏ) {
            int ˋ = i - (i2 - this.ˎ.ˋ(i2));
            if (ˋ == 0) {
                while (this.ˎ.ˏ(i2)) {
                    i2++;
                }
                return i2;
            }
            i2 += ˋ;
        }
        return -1;
    }

    public void ˏ(View view) {
        int ˋ = this.ˊ.ˋ(view);
        if (ˋ >= 0) {
            if (this.ˎ.ˎ(ˋ)) {
                ʼ(view);
            }
            this.ˊ.ˎ(ˋ);
        }
    }

    public void ॱ(int i) {
        int ʼ = ʼ(i);
        View ˋ = this.ˊ.ˋ(ʼ);
        if (ˋ != null) {
            if (this.ˎ.ˎ(ʼ)) {
                ʼ(ˋ);
            }
            this.ˊ.ˎ(ʼ);
        }
    }

    public View ˎ(int i) {
        return this.ˊ.ˋ(ʼ(i));
    }

    public void ॱ() {
        this.ˎ.ˏ();
        for (int size = this.ˏ.size() - 1; size >= 0; size--) {
            this.ˊ.ˎ((View) this.ˏ.get(size));
            this.ˏ.remove(size);
        }
        this.ˊ.ˎ();
    }

    public View ˏ(int i) {
        int size = this.ˏ.size();
        for (int i2 = 0; i2 < size; i2++) {
            View view = (View) this.ˏ.get(i2);
            s ˊ = this.ˊ.ˊ(view);
            if (ˊ.ˏ() == i && !ˊ.ॱˊ() && !ˊ.ʻॱ()) {
                return view;
            }
        }
        return null;
    }

    public void ॱ(View view, int i, LayoutParams layoutParams, boolean z) {
        int ˏ;
        if (i < 0) {
            ˏ = this.ˊ.ˏ();
        } else {
            ˏ = ʼ(i);
        }
        this.ˎ.ˊ(ˏ, z);
        if (z) {
            ᐝ(view);
        }
        this.ˊ.ˏ(view, ˏ, layoutParams);
    }

    public int ˊ() {
        return this.ˊ.ˏ() - this.ˏ.size();
    }

    public int ˋ() {
        return this.ˊ.ˏ();
    }

    public View ˋ(int i) {
        return this.ˊ.ˋ(i);
    }

    public void ˊ(int i) {
        int ʼ = ʼ(i);
        this.ˎ.ˎ(ʼ);
        this.ˊ.ॱ(ʼ);
    }

    public int ॱ(View view) {
        int ˋ = this.ˊ.ˋ(view);
        if (ˋ == -1 || this.ˎ.ˏ(ˋ)) {
            return -1;
        }
        return ˋ - this.ˎ.ˋ(ˋ);
    }

    public boolean ˋ(View view) {
        return this.ˏ.contains(view);
    }

    public void ˎ(View view) {
        int ˋ = this.ˊ.ˋ(view);
        if (ˋ < 0) {
            throw new IllegalArgumentException("view is not a child, cannot hide " + view);
        }
        this.ˎ.ॱ(ˋ);
        ᐝ(view);
    }

    public void ˊ(View view) {
        int ˋ = this.ˊ.ˋ(view);
        if (ˋ < 0) {
            throw new IllegalArgumentException("view is not a child, cannot hide " + view);
        } else if (this.ˎ.ˏ(ˋ)) {
            this.ˎ.ˊ(ˋ);
            ʼ(view);
        } else {
            throw new RuntimeException("trying to unhide a view that was not hidden" + view);
        }
    }

    public String toString() {
        return this.ˎ.toString() + ", hidden list:" + this.ˏ.size();
    }

    public boolean ʻ(View view) {
        int ˋ = this.ˊ.ˋ(view);
        if (ˋ == -1) {
            return ʼ(view) ? true : true;
        } else {
            if (!this.ˎ.ˏ(ˋ)) {
                return false;
            }
            this.ˎ.ˎ(ˋ);
            if (ʼ(view)) {
                this.ˊ.ˎ(ˋ);
            } else {
                this.ˊ.ˎ(ˋ);
            }
            return true;
        }
    }
}
